﻿using System;
using System.Collections.Generic;
using System.Text;

namespace AdaptiveAgents.Results
{
    public class ExperimentResults
    {
        private const int player0 = 0;
        private const int player1 = 1;
        private const int player2 = 2;

        private int lastPlayerPlayed = -1;

        public int numberOfTurnsPlayer0Played;
        public int numberOfTurnsPlayer1Played;
        public int numberOfTurnsPlayer2Played;

        //public double player0AvarageProfit;
        //public double player1AvarageProfit;
        //public double player2AvarageProfit;

        public double player0AccumilatingProfit;
        public double player1AccumilatingProfit;
        public double player2AccumilatingProfit;

        public ExperimentResults()
        {
            InitializeResults();
        }

        public void IncreasePlayerNumberOfTurnsPlayed(int playerNumber)
        {
            switch (playerNumber)
            {
                case player0:
                    numberOfTurnsPlayer0Played++;
                    lastPlayerPlayed = 0;
                    break;
                case player1:
                    numberOfTurnsPlayer1Played++;
                    lastPlayerPlayed = 1;
                    break;
                case player2:
                    numberOfTurnsPlayer2Played++;
                    lastPlayerPlayed = 2;
                    break;
            }
        }

        public void IncreasePlayerAccumilatingProfit(int playerNumber, double profit)
        {
            switch (playerNumber)
            {
                case player0:
                    player0AccumilatingProfit += profit;
                    break;
                case player1:
                    player1AccumilatingProfit += profit;
                    break;
                case player2:
                    player2AccumilatingProfit += profit;
                    break;
            }
        }

        //public void IncreasePlayerAvarageProfit(int playerNumber, double profit)
        //{
        //    switch (playerNumber)
        //    {
        //        case player0:
        //            player0AvarageProfit += profit;
        //            break;
        //        case player1:
        //            player1AvarageProfit += profit;
        //            break;
        //        case player2:
        //            player2AvarageProfit += profit;
        //            break;
        //    }
        //}

        public void InitializeResults()
        {
            InitializeNumberOfTurnsPlayedByPlayers();
            //InitializePlayersAvarageProfit();
            InitializePlayersAccumilatingProfit();
        }

        public void InitializeNumberOfTurnsPlayedByPlayers()
        {
            numberOfTurnsPlayer0Played = numberOfTurnsPlayer1Played = numberOfTurnsPlayer2Played = 0;
        }

        //public void InitializePlayersAvarageProfit()
        //{
        //    player0AvarageProfit = player1AvarageProfit = player2AvarageProfit = 0;
        //}

        public void InitializePlayersAccumilatingProfit()
        {
            player0AccumilatingProfit = player1AccumilatingProfit = player2AccumilatingProfit = 0;
        }
    }
}
